// Copyright  2012 Petr TALLA. [petr.talla@gmail.com]
// This file is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This file is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY;  without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
// [http://www.gnu.org/copyleft/lesser.html]
//=============================================================================
package tc.common.utility;

public class Angle {
	enum Units { DEG, RAD};
	
	private double value;
	
	public Angle(double value, Units units) {
		if (units == Units.DEG) 
		{	value = degToRad(value);
		}
				
		assert value <  100.0;
		assert value > -100.0;
		while ( this.value > 2.0*Math.PI ) value -= 2.0*Math.PI;
		while (this.value < 0.0 ) value += 2.0*Math.PI;
				
		this.value = value; 
	}
	
	public Angle(double value) {
		this.value = degToRad(value);
	}
	
	public double getRAD() {
		return value;
	}
	
	public double getDEG() {
		return value * Math.PI / 180.0;
	}
	
	public static double radToDeg(double value) {
		return value * 180.0 / Math.PI;
	}
	
	public static double degToRad(double value) {
		return value * Math.PI / 180.0; 
	}

}
